<template>
  <el-container>
    <el-aside :width="menuCollapse?'65px':'200px'" >
      <!-- el-menu 是有子菜单 -->
        <el-menu
          background-color="#353B4E"
          text-color="#fff"
          active-text-color="#3C9DFF"
          :collapse="menuCollapse"
          :collapse-transition="false"
        >
        <!-- el-menu-item 叶子子菜单 无子菜单 -->
        <el-menu-item index="1" :style="{width:menuCollapse?'65px':'200px'}">
         <i class="el-icon-s-home"></i>
          <span slot="title">首页</span>
        </el-menu-item>
          <el-submenu index="2" :style="{width:menuCollapse?'65px':'200px'}">
            <!-- 默认显示标题 -->
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>内容管理</span>
            </template>
            <el-menu-item index="2-1">文章发布</el-menu-item>
            <el-menu-item index="2-2">内容列表</el-menu-item>
            <el-menu-item index="2-3">评论列表</el-menu-item>
            <el-menu-item index="2-4">素材管理</el-menu-item>
            <!-- <el-menu-item-group>
              <template slot="title">分组一</template>
              <el-menu-item index="1-1">选项1</el-menu-item>
              <el-menu-item index="1-2">选项2</el-menu-item>
            </el-menu-item-group>
            <el-menu-item-group title="分组2">
              <el-menu-item index="1-3">选项3</el-menu-item>
            </el-menu-item-group>
            <el-submenu index="1-4">
              <template slot="title">选项4</template>
              <el-menu-item index="1-4-1">选项1</el-menu-item>
            </el-submenu> -->
          </el-submenu>
          <el-submenu index="3" :style="{width:menuCollapse?'65px':'200px'}">
            <template slot="title">
              <i class="el-icon-menu"></i>
              <span slot="title">粉丝管理</span>
            </template>
            <el-menu-item index="3-1">图文数据</el-menu-item>
            <el-menu-item index="3-2">粉丝概况</el-menu-item>
            <el-menu-item index="3-3">粉丝画像</el-menu-item>
            <el-menu-item index="3-4">粉丝列表</el-menu-item>
          </el-submenu>
          <el-menu-item index="4" :style="{width:menuCollapse?'65px':'200px'}">
            <i class="el-icon-setting"></i>
            <span slot="title">账户信息</span>
          </el-menu-item>
        </el-menu>

    </el-aside>
    <el-container>
      <el-header>
        <div class="youbian">
          <el-input placeholder="请输入文章名字"></el-input>
          <span class="ms">消息</span>
          <div>
            <el-avatar :src="photo"></el-avatar>
          </div>
          <!-- <img :src="photo" alt width="40" /> -->
          <el-dropdown trigger="click">
            <span class="el-dropdown-link">
              {{name}}
              <i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>个人信息</el-dropdown-item>
              <el-dropdown-item>github地址</el-dropdown-item>
              <el-dropdown-item @click.native="logout()">退出</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
        <div class="zuobian">
          <i slot="prefix"
            :class="menuCollapse?'el-icon-s-unfold':'el-icon-s-fold'"
            style="cursor:pointer;"
            @click="menuCollapse=!menuCollapse"
         ></i>
          <span>江苏传智播客教育科技股份有限公司</span>
        </div>
      </el-header>
      <el-main>
        <router-view>
        </router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  data () {
    return {
      menuCollapse: true
    }
  },
  computed: {
    name () {
      return window.sessionStorage.getItem('name')
    },
    photo () {
      return window.sessionStorage.getItem('photo')
    }
  },
  methods: {
    logout () {
      this.$confirm('是否退出系统', '退出', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          window.sessionStorage.clear()
          this.$router.push({ name: 'login22' })
          this.$message({
            type: 'success',
            message: '退出成功!'
          })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消退出'
          })
        })
    },
    handleOpen (key, keyPath) {
      console.log(key, keyPath)
    },
    handleClose (key, keyPath) {
      console.log(key, keyPath)
    }
  }
}
</script>

<style lang="less" scoped>
.el-container {
  height: 100%;
  .el-aside {
    background-color: #323745;
  }
  .el-header {
    // background-color: orange;
    background-color: #fff;
    .zuobian {
      width: 400px;
      height: 60px;
      line-height: 60px;
      float: left;
    }
    .youbian {
      width: 450px;
      height: 60px;
      float: right;
      display: flex;
      justify-content: center;
      align-items: center;
      .ms {
        width: 120px;
        margin: 0 10px;
      }
      .el-dropdown {
        width: 340px;
        display: flex;
        justify-content: center;
        align-items: center;
      }
    }
  }
  .el-main {
    background-color: #f2f3f5;
  }
}
</style>
